<?php
$con = mysql_connect ( "localhost", "root", "" );
if (! $con) {
	die ( 'KhÃ´ng thá»ƒ káº¿t ná»‘i Ä‘áº¿n database: ' . mysql_error () );
}

mysql_select_db ( "demo_mysql", $con );

$result = mysql_query ( "SELECT user.username,user.password,class.name FROM user LEFT JOIN class ON user.class=class.id ORDER BY user.username" );
if (mysql_num_rows ( $result ) > 0) {
	echo "<table border='1' cellpadding='5px'>
	<tr>
	<th>Username</th>
	<th>Password</th>
	<th>Class</th>
	<th>Remove</th>
	<th>Edit</th>
	<th><a href='http://localhost/php/add_user.php'>Add</a></th>		
	</tr>";
	while ( $row = mysql_fetch_array ( $result ) ) {
		echo $row;
		echo "<tr>";
		echo "<td>" . $row ['username'] . "</td>";
		echo "<td>" . $row ['password'] . "</td>";
		echo "<td>" . $row ['class'] . "</td>";
		echo "<td><a href='http://localhost/php/del_user.php?userid=".$row['user.id']."'>remove</a></td>";
		echo "<td><a href='http://localhost/php/edit_user.php?userid=".$row['user.id']."'>edit</a></td>";
		echo "</tr>";
	}
	echo "</table>";
}
mysql_close ( $con );
?>